﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Scripting.Ast;
using Microsoft.Scripting;
using Microsoft.Linq.Expressions;

namespace DlrBasic.Parser.Ast
{
    class Mat : Statement
    {
        VariableOrCall expression;

        public Mat(SourceSpan span, VariableOrCall expression)
            : base(span)
        {
            this.expression = expression;
        }

        protected internal override Expression Generate(DlrBasicGenerator generator, StateMemberGenerator stateParameter, LambdaBuilder builder)
        {
            SymbolId name = SymbolTable.StringToCaseInsensitiveId(expression.Name);

            return Expression.Block(
                Expression.Call(stateParameter.GetMemoryVariable(),
                    typeof(Runtime.DlrBasicMemory).GetMethod("ZeroArray"),
                    Expression.Constant(name)),
                base.Generate(generator, stateParameter, builder));
        }
    }
}
